using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Zero.Entity.Models.Mapping
{
    public class Sys_ButtonMap : EntityTypeConfiguration<Sys_Button>
    {
        public Sys_ButtonMap()
        {
            // Primary Key
            this.HasKey(t => t.BtnID);

            // Properties
            this.Property(t => t.BtnID)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.BtnName)
                .HasMaxLength(50);

            this.Property(t => t.BtnNo)
                .HasMaxLength(50);

            this.Property(t => t.BtnClass)
                .HasMaxLength(50);

            this.Property(t => t.BtnIcon)
                .HasMaxLength(100);

            this.Property(t => t.BtnScript)
                .HasMaxLength(200);

            this.Property(t => t.MenuID)
                .HasMaxLength(50);

            this.Property(t => t.InitStatus)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Sys_Button");
            this.Property(t => t.BtnID).HasColumnName("BtnID");
            this.Property(t => t.BtnName).HasColumnName("BtnName");
            this.Property(t => t.BtnNo).HasColumnName("BtnNo");
            this.Property(t => t.BtnClass).HasColumnName("BtnClass");
            this.Property(t => t.BtnIcon).HasColumnName("BtnIcon");
            this.Property(t => t.BtnScript).HasColumnName("BtnScript");
            this.Property(t => t.MenuID).HasColumnName("MenuID");
            this.Property(t => t.InitStatus).HasColumnName("InitStatus");
            this.Property(t => t.SeqNo).HasColumnName("SeqNo");
            this.Property(t => t.CreateUserID).HasColumnName("CreateUserID");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.ModifyUserID).HasColumnName("ModifyUserID");
            this.Property(t => t.ModifyDate).HasColumnName("ModifyDate");
            this.Property(t => t.IsEnable).HasColumnName("IsEnable");
            this.Property(t => t.OrderIndex).HasColumnName("OrderIndex");

            // Relationships
            this.HasOptional(t => t.Sys_Menu)
                .WithMany(t => t.Sys_Buttons)
                .HasForeignKey(d => d.MenuID);

        }
    }
}
